import axios from "axios";
const url = import.meta.env.VITE_backurl;
const urlJava = import.meta.env.VITE_javaurl;
// let url = 'http://10.253.0.3:1005/htdl'
export const SaveState = (data) => {
  let u = url + "/addRecord";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// /State/SelectByStateAndDate?state=a&date=2024-05-13

// export const SelectByStateAndDate = (state, date) => {
//     let u = url + '/getRecordByDateAndState?state=' + state + '&date=' + date;
//     return axios({
//         url: u,
//         method: 'get',
//     })
// }

export const SelectByStateAndDate = (data) => {
  let u = url + "/getRecordByDateAndState";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getBargeShip
export const getBargeShip = () => {
  let u = url + "/getBargeShip";
  return axios({
    url: u,
    method: "get",
  });
};

// getFisherShip
export const getFisherShip = () => {
  let u = url + "/getFisherShip";
  return axios({
    url: u,
    method: "get",
  });
};

// upload
export const upload = (data) => {
  let u = url + "/upload";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// updateRecord
export const updateRecord = (data) => {
  let u = url + "/updateRecord";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getDayData
export const getDayData = (data) => {
  let u = url + "/getDayData";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getShipData
export const getShipData = (data) => {
  let u = url + "/getShipData";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getAreaData
export const getAreaData = (data) => {
  let u = url + "/getAreaData";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getBargeShipData
export const getBargeShipData = (data) => {
  let u = url + "/getBargeShipData";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getAreaDataByDate
export const getAreaDataByDate = (data) => {
  let u = url + "/getAreaDataByDate";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getArea
export const getArea = () => {
  let u = url + "/getArea";
  return axios({
    url: u,
    method: "get",
  });
};

// getTotalData
export const getTotalData = (data) => {
  let u = url + "/getTotalData";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getCompleteData
export const getCompleteData = (data) => {
  let u = url + "/getCompleteDataOnly";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// addDisposalRecord
export const addDisposalRecord = (data) => {
  let u = url + "/addDisposalRecord";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getDisposalRecord
export const getDisposalRecord = (data) => {
  let u = url + "/getDisposalRecord";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// getAllRecord
export const getAllRecord = (bargeShip) => {
  let u = url + "/getAllRecord";
  return axios({
    url: u,
    method: "post",
    params: {
      bargeShip,
    },
  });
};

// getAllDisposalRecord
export const getAllDisposalRecord = () => {
  let u = url + "/getAllDisposalRecord";
  return axios({
    url: u,
    method: "post",
  });
};

// 通用的获取文件
export const getFile = (data) => {
  let u = url + data;
  return axios({
    url: u,
    method: "get",
  });
};

// exportDataToExcel
export const exportDataToExcel = (data) => {
  let u = url + "/exportDataToExcel";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
};

// deleteRecordById
export const deleteRecordById = (data) => {
  let u = url + "/deleteRecordById";
  return axios({
    url: u,
    method: "post",
    params: data,
  });
};

// 	r.POST("/deleteBargeShip", controller.Ship.DeleteBargeShip)
// r.POST("/deleteFisherShip", controller.Ship.DeleteFisherShip)
// r.POST("/addBargeShip", controller.Ship.AddBargeShip)
// r.POST("/addFisherShip", controller.Ship.AddFisherShip)

export const deleteBargeShip = (id) => {
  let u = url + "/deleteBargeShip";
  return axios({
    url: u,
    method: "post",
    params: {
      id,
    },
  });
};

export const deleteFisherShip = (id) => {
  let u = url + "/deleteFisherShip";
  return axios({
    url: u,
    method: "post",
    params: {
      id,
    },
  });
};

export const addBargeShip = (data) => {
  let u = url + "/addBargeShip";
  return axios({
    url: u,
    method: "post",
    data,
  });
};

export const addFisherShip = (data) => {
  let u = url + "/addFisherShip";
  return axios({
    url: u,
    method: "post",
    data,
  });
};

// addFisherShipFile
export const addFisherShipFile = (data) => {
  let u = url + "/addFisherShipFile";
  return axios({
    url: u,
    method: "post",
    data,
  });
};

// deleteUser
export const deleteUser = (id) => {
  let u = url + "/deleteUser";
  return axios({
    url: u,
    method: "post",
    params: {
      id,
    },
  });
};

// addUser
export const addUser = (data) => {
  let u = url + "/addUser";
  return axios({
    url: u,
    method: "post",
    data,
  });
};

// getUser
export const getUser = () => {
  let u = url + "/getUser";
  return axios({
    url: u,
    method: "get",
  });
};

// editUser
export const editUser = (data) => {
  let u = url + "/editUser";
  return axios({
    url: u,
    method: "post",
    data,
  });
};

// http://39.103.180.154:5000/bhshipservice/WebService1.asmx/GetALLLiveLoc_JK
// 获取船舶名单
export const GetALLLiveLoc_JK = () => {
  let u = "http://39.103.180.154:5000/bhshipservice/WebService1.asmx/GetALLLiveLoc_JK"
  return axios({
    url: u,
    method: "get",
  });
}

// 然后通过船名拿编号   http://gg.oceanread.com:1005/VideoCamera_back/ShipToCamera/getCameraIndexIdByShipName
export const getCameraIndexIdByShipName = (data) => {
  let u = 'http://gg.oceanread.com:1005/VideoCamera_back/ShipToCamera/getCameraIndexIdByShipName'
  return axios({
    url: u,
    method: "get",
    params: {
      shipname: data.shipName
    }
  });
}

// http://gg.oceanread.com:1005/VideoCamera_back/ShipToCamera/getKeepTime
export const getKeepTime = (data) => {
  let u = 'http://gg.oceanread.com:1005/VideoCamera_back/ShipToCamera/getKeepTime'
  return axios({
    url: u,
    method: "get",
    params: {
      cameraindexid: data.indexId,
      startTime: data.startTime,
      endTime: data.endTime,
    }
  });
}

export const getReport = (data) => {
  let u = urlJava + "/report";
  return axios({
    url: u,
    method: "post",
    data: data,
  });
}

export const upLoadPng = (data) => {
  let u = urlJava + "/upload";
  return axios({
    url: u,
    method: "post",
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// clear
export const clearPng = () => {
  let u = urlJava + "/clear";
  return axios({
    url: u,
    method: "get",
  });
};

// 获取特定文件
export const getReportFile = (data) => {
  let u = urlJava + "/public/" + data;
  return axios({
    url: u,
    method: "get",
    responseType: 'blob'
  });
}

// 	//GetYesterdayRecord

export const getYesterdayRecord = (bargeShip) => {
  let u = url + "/getYesterdayRecord";
  return axios({
    url: u,
    method: "post",
    params: {
      bargeShip,
    },
  });
};